import Vue from 'vue'
// 导入路由管理器
import VueRouter from 'vue-router'
import Home from '@/views/Home'
import Layout from '@/views/Layout'
import Play from '@/views/Play'
import Search from '@/views/Search'
// 在VUE组件中使用路由管理器组件（router-view/router-link)
Vue.use(VueRouter)
// 定义规则
const routes = [
    {
        path: '/',
        redirect: '/layout'
    },
    {
        path: '/layout',
        component: Layout,
        redirect: '/layout/home',
        children: [
            {
                path: 'home',
                component: Home,
                meta: {
                    title: '首页',
                }
            },
            {
                path: 'search',
                component: Search,
                meta: {
                    title: '搜索',
                }
            },
        ]
    },
    {
        path: '/play',
        component: Play
    },
]
// 在路由管理器中注册规则
const router = new VueRouter({
    routes
})
// 导出带规则的路由管理
export default router